//监控输入框输入的长度
var oDiv=$('.gma-value');
common.goBackNext();
baseInfoForm.counterCtrl({
	targetSelector:oDiv,
	counterSelector:$('.gma-counter'),
	length:50,
	noticeMsg:'反馈内容已达到上限'
});
var $id=$('#agentId');
var $token=$('#token');
var data=common.getLocalData('H5-agentInfo');
if(!data){
	window.location.href="login.html";
}else{
	var token=common.getToken();
	var id=data.id;
	if(token&&id){
		$id.val(data.id);
		$token.val(token);
		var globalHost=common.globalHost;
		var saveFeedbackPort=common.saveFeedbackPort;
		var url=globalHost+saveFeedbackPort;
		baseInfoForm.submit.on('tap',function(e){
			var $this=$(this);
			var textareaResult= baseInfoForm.testMobileCode({targetSelector:oDiv,noticeMsg:'输入不能为空'})
			var checkCase=$this.hasClass("act-ago");
			var sendData=common.getSendDataByForm(baseInfoForm.form);
			if(!!textareaResult&&!!checkCase){
    			$this.removeClass("act-ago").addClass("acted-yet");
				baseInfoForm.formPost({
		            sendData:sendData,
		            url:url,
		            resSuccess:function(data){
		            	actedStyle ();
						baseInfoForm.form[0].reset();
						setTimeout(function(){
							window.location.href="index.html";
						},1000)	    
		            },
		            resFailed:function(data){
		            	//判断token失效
		            	actAgoStyle (); 
		            }
		       }); 
			}else{
				console.log('不准发送ajax');
			}
			e.preventDefault();
		    return false;
		})
	}else{
		window.location.href="login.html";
	}
};
function actedStyle () {
	baseInfoForm.submit.removeClass("act-ago").addClass("acted-yet");
}
function actAgoStyle () {
	baseInfoForm.submit.removeClass("acted-yet").addClass("act-ago");
}